package com.sunlee.common.service.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sunlee.common.core.constant.Constant;
import com.sunlee.common.core.entity.PageData;
import com.sunlee.common.core.utils.ConvertUtils;
import com.sunlee.common.service.dao.SysLogErrorDao;
import com.sunlee.common.service.dto.SysLogErrorDTO;
import com.sunlee.common.service.entity.SysLogErrorEntity;
import com.sunlee.common.service.service.SysLogErrorService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 异常日志
 *
 * @author sunlee
 */
@Service
public class SysLogErrorServiceImpl extends CrudServiceImpl<SysLogErrorDao, SysLogErrorEntity, SysLogErrorDTO> implements SysLogErrorService {

    @Override
    public PageData<SysLogErrorDTO> page(Map<String, Object> params) {
        IPage<SysLogErrorEntity> page = baseDao.selectPage(
                getPage(params, Constant.CREATE_DATE, false),
                new LambdaQueryWrapper<>()
        );

        return getPageData(page, SysLogErrorDTO.class);
    }

    @Override
    public List<SysLogErrorDTO> listOwn(Map<String, Object> params) {
        List<SysLogErrorEntity> entityList = baseDao.selectList(new LambdaQueryWrapper<>());
        return ConvertUtils.sourceToTarget(entityList, SysLogErrorDTO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveOwn(SysLogErrorEntity entity) {
        insertOwn(entity);
    }

}